//初始化页面
$(function() {
	//头部（判断是否已登录）
	var uid = localStorage.getItem("shipinUid");
	//首页轮播图
	var action3 = "/appsfenlei/SFenlei.ph";
		//action3 = "/liqiang365/SFenlei.ph";
	ajaxWeb(action3, null, function(data3) {
		var tr = "";
		tr += "<div class=\"bd\"><ul>";
		var obj3 = data3.resobj.lunboimgs;
		if(data3.code=="40000") {
			for(var i=0;i<obj3.length;i++) {
				tr += "<a href=\""+obj3[i].pcDiZhi+"\" target=\"_blank\"><li style=\"background:url("+obj3[i].pcimg+") no-repeat center; width:926px; background-size:100% 100%;\"></li></a>";
			}
		}
		tr += "</ul></div>";
		tr += "<div class=\"hd\">";
		tr += "<ul></ul>";
		tr += "</div>";
		$("#lunbo").html(tr);
		lunboshow();//显示轮播图
	},'json')
	
	//最热视频
	var action4 = "/appSShipin/selectHotShipin.ph";
		//action4 = "/liqiang365/selectHotShipin.ph";
	ajaxWeb(action4, null, function(data4) {
		var tr = "";
		var obj4 = data4.resobj;
		if(data4.code=="40000") {
			for(var i=0;i<obj4.length;i++) {
				tr += "<li>";
				if(i==0||i==1||i==2) {
					tr += "<b class=\"on\" style=\"float:left;\">"+(i+1)+"</b>";
				}else{
					tr += "<b style=\"float:left;\">"+(i+1)+"</b>";
				}
				tr +="<a style=\"margin-left: 8px;display:inline-block;\" href=\"kechengxiangqing.html?zjid="+obj4[i].zjid+"&kcid="+obj4[i].kcid+"\"><span class=\"span_\">"+obj4[i].name+"</span><em class=\"em_\">"+obj4[i].bofangliang+"</em></a>";
				tr += "</li>";
			}
		}
		$("#hot-sp").html(tr);
	},'json')
	
	//最新视频
	var action5 = "/appSShipin/selectNewShipin.ph";
	ajaxWeb(action5, null, function(data5) {
		var tr = "";
		var obj5 = data5.resobj;
		if(data5.code=="40000") {
			for(var i=0;i<obj5.length;i++) {
				tr += "<li>";
				if(i==0||i==1||i==2) {
					tr += "<b class=\"on\" style=\"float:left;\">"+(i+1)+"</b>";
				}else{
					tr += "<b style=\"float:left;\">"+(i+1)+"</b>";
				}
				tr +="<a style=\"margin-left: 8px;display:inline-block;\" href=\"kechengxiangqing.html?zjid="+obj5[i].zjid+"&kcid="+obj5[i].kcid+"\"><span class=\"span_\">"+obj5[i].name+"</span><span style=\"vertical-align:top;\" class=\"em_\">"+obj5[i].createtime.substr(0,10)+"</span></a>";
				tr += "</li>";
			}
		}
		$("#new-sp").html(tr);
	},'json')
	
	//最热、最新视频切换
	$(".change-list-tab a").hover(function() {
		$(".sel-sp").hide();
		var data = $(this).data("li");
		$("#"+data+"").show();
		$(".change-list-tab a").removeClass("active_");
		$(this).addClass("active_");
	});
	
	//热门视频
	var action6 = "/appsfenlei/SFenlei.ph";
	ajaxWeb(action6, null, function(data6) {
		var obj = data6.resobj.fenleis;
		var tr = "";
		for(var i=0;i<obj.length;i++) {
			if(i==0) {
				tr += "<h3 class=\"lm-tit1\" style=\"line-heig" +
						"ht:40px;height:40px;margin-bottom:15px;\"><span>热门视频</span><!--<a href=\"gengduoshipin.html?zjid="+obj[i].zjid+"\">更1多</a>--></h3>";
				tr += "<div class=\"row-1 fix\">";
				tr += "<div class=\"col-l bgc-a\">";
				tr += "<div class=\"copy\">";
				tr += "<h3>"+obj[i].name+"</h3>";
				var action7 = "/appsfenlei/selectSFenleiTwo.ph?fflid="+obj[i].zjid+"";
				ajaxPostAsyncData(action7, null, function(data7) {
					var obj7 = data7.resobj;
					for(var j=0;j<obj7.length;j++) {
						if(j==0) {
							tr += "<span id=\"erji"+i+"\" onclick=\"erji('"+obj7[j].zjid+"','"+i+"');\">"+obj7[j].name+"</span>";
						}else{
							tr += "<span id=\"erji"+i+"\" onclick=\"erji('"+obj7[j].zjid+"','"+i+"');\">"+obj7[j].name+"</span>";
						}
						
					}
				},'json')
				tr += "</div>";
				tr += "</div>";
				tr += "<span id=\"con_sp\" class=\"erjis"+i+"\">";
				tr += "<div class=\"col-c\">";
				tr += "<div class=\"pic\">";
				
				ajaxPostAsyncData(action7, null, function(data7) {
					var obj7 = data7.resobj;
					var map = {};
					map["fflid"]=obj7[0].zjid;
					map["type"]="1";
					var action8 = "/appsfenlei/selectSFenleikc.ph";
					ajaxPostAsyncData(action8, map, function(data8) {
						var obj8 = data8.resobj.rows;
						var img = obj8[0].imgpcurl;
						var action9 = "/appSShipin/selectByshipin.ph";
						var map1 = {};
						map1["index"]=7;
						map1["zjid"]=obj8[0].zjid;
						ajaxPostAsyncData(action9, map1, function(data9) {
							var obj9 = data9.resobj.rows;
							for(var k=0;k<obj9.length;k++) {
								if(k==0) {
									tr += "<a href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\">";
									tr += "<p>"+obj9[k].name+"</p></a>";
									tr += "</div>";
									tr += "</div>";
									tr += "<div style=\"width:574px;float:left;\" class=\"col-r\">";
									tr += "<div class=\"ul-video\">";
									tr += "<ul>";
								}else {
									tr += "<li><a style=\"margin-left:30px;\" href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\"><p>"+obj9[k].name+"</p></a></li>";
								}
							}
						},'json')
					},'json')
				},'json')
				tr += "</ul>";
				tr += "</div>";
				tr += "</div>";
				tr += "</div>";
				tr += "</span>";
			}else if(i==2) {
				tr += "<h3 class=\"lm-tit1\" style=\"line-height:40px;height:40px;\"><!--<a href=\"gengduoshipin.html?zjid="+obj[i].zjid+"\">更多</a>--></h3>";
				tr += "<div class=\"row-1 fix\">";
				tr += "<div style=\"\" class=\"col-l bgc-c\">";
				tr += "<div class=\"copy\">";
				tr += "<h3>"+obj[i].name+"</h3>";
				var action7 = "/appsfenlei/selectSFenleiTwo.ph?fflid="+obj[i].zjid+"";
				ajaxPostAsyncData(action7, null, function(data7) {
					var obj7 = data7.resobj;
					for(var j=0;j<obj7.length;j++) {
						if(j==0) {
							tr += "<span id=\"erji"+i+"\" onclick=\"erji('"+obj7[j].zjid+"','"+i+"');\">"+obj7[j].name+"</span>";
						}else{
							tr += "<span id=\"erji"+i+"\" onclick=\"erji('"+obj7[j].zjid+"','"+i+"');\">"+obj7[j].name+"</span>";
						}
						
					}
				},'json')
				tr += "</div>";
				tr += "</div>";
				tr += "<span id=\"con_sp\" class=\"erjis"+i+"\">";
				tr += "<div class=\"col-c\">";
				tr += "<div class=\"pic\">";
				
				ajaxPostAsyncData(action7, null, function(data7) {
					var obj7 = data7.resobj;
					var map = {};
					map["fflid"]=obj7[0].zjid;
					map["type"]="1";
					var action8 = "/appsfenlei/selectSFenleikc.ph";
					ajaxPostAsyncData(action8, map, function(data8) {
						var obj8 = data8.resobj.rows;
						var img = obj8[0].imgpcurl;
						var action9 = "/appSShipin/selectByshipin.ph";
						var map1 = {};
						map1["index"]=7;
						map1["zjid"]=obj8[0].zjid;
						ajaxPostAsyncData(action9, map1, function(data9) {
							var obj9 = data9.resobj.rows;
							for(var k=0;k<obj9.length;k++) {
								if(k==0) {
									tr += "<a href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\">";
									tr += "<p>"+obj9[k].name+"</p></a>";
									tr += "</div>";
									tr += "</div>";
									tr += "<div style=\"width:574px;float:left;\" class=\"col-r\">";
									tr += "<div class=\"ul-video\">";
									tr += "<ul>";
								}else {
									tr += "<li><a style=\"margin-left:30px;\" href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\"><p>"+obj9[k].name+"</p></a></li>";
								}
							}
						},'json')
					},'json')
				},'json')
				tr += "</ul>";
				tr += "</div>";
				tr += "</div>";
				tr += "</div>";
				tr += "</span>";
				
				tr += "<div class=\"box-bj box-bj1\">";
				tr += "<div style=\"height:250px;\" class=\"bd\">";
				tr += "<ul>";
				var action1 = "/appSAdv/selectSAdv.ph";
				ajaxPostAsyncData(action1, null, function(data1) {
					var obj1 = data1.resobj;
					for(var i=0;i<obj1.length;i++) {
						tr += "<a href=\""+obj1[i].pcDiZhi+"\" target=\"_blank\"><li style=\"background:url('"+obj1[i].pcimgurl+"') no-repeat; background-size:100% 100%;cursor: pointer;width:1200px;\"></li></a>";
					}
				},'json')
				tr += "</ul>";
				tr += "</div>";
				tr += "<div class=\"hd\">";
				tr += "<ul></ul>";
				tr += "</div>";
				tr += "</div>";
			}else {
				tr += "<h3 class=\"lm-tit1\" style=\"line-height:40px;height:40px;\"><!--<a href=\"gengduoshipin.html?zjid="+obj[i].zjid+"\">更多</a>--></h3>";
				tr += "<div class=\"row-1 fix\">";
				if(i==1) {
					tr += "<div class=\"col-l bgc-b\">";
				}else if(i==3) {
					tr += "<div class=\"col-l bgc-d\">";
				}else if(i==4) {
					tr += "<div class=\"col-l bgc-e\">";
				}else if(i==5) {
					tr += "<div class=\"col-l bgc-f\">";
				}else if(i==6) {
					tr += "<div class=\"col-l bgc-g\">";
				}else if(i==7) {
					tr += "<div class=\"col-l bgc-h\">";
				}
				
				tr += "<div class=\"copy\">";
				tr += "<h3>"+obj[i].name+"</h3>";
				var action7 = "/appsfenlei/selectSFenleiTwo.ph?fflid="+obj[i].zjid+"";
				ajaxPostAsyncData(action7, null, function(data7) {
					var obj7 = data7.resobj;
					for(var j=0;j<obj7.length;j++) {
						if(j==0) {
							tr += "<span class=\"erji"+i+"\" onclick=\"erji('"+obj7[j].zjid+"','"+i+"');\">"+obj7[j].name+"</span>";
						}else{
							tr += "<span class=\"erji"+i+"\" onclick=\"erji('"+obj7[j].zjid+"','"+i+"');\">"+obj7[j].name+"</span>";
						}
						
					}
				},'json')
				tr += "</div>";
				tr += "</div>";
				tr += "<span id=\"con_sp\" class=\"erjis"+i+"\">";
				tr += "<div class=\"col-c\">";
				tr += "<div class=\"pic\">";
				
				ajaxPostAsyncData(action7, null, function(data7) {
					var obj7 = data7.resobj;
					var map = {};
					map["fflid"]=obj7[0].zjid;
					map["type"]="1";
					var action8 = "/appsfenlei/selectSFenleikc.ph";
					ajaxPostAsyncData(action8, map, function(data8) {
						var obj8 = data8.resobj.rows;
						var img = obj8[0].imgpcurl;
						var action9 = "/appSShipin/selectByshipin.ph";
						var map1 = {};
						map1["index"]=7;
						map1["zjid"]=obj8[0].zjid;
						ajaxPostAsyncData(action9, map1, function(data9) {
							var obj9 = data9.resobj.rows;
							for(var k=0;k<obj9.length;k++) {
								if(k==0) {
									tr += "<a href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\">";
									tr += "<p>"+obj9[k].name+"</p></a>";
									tr += "</div>";
									tr += "</div>";
									tr += "<div style=\"width:574px;float:left;\" class=\"col-r\">";
									tr += "<div class=\"ul-video\">";
									tr += "<ul>";
								}else {
									tr += "<li><a style=\"margin-left:30px;\" href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\"><p>"+obj9[k].name+"</p></a></li>";
								}
							}
						},'json')
					},'json')
				},'json')
				tr += "</ul>";
				tr += "</div>";
				tr += "</div>";
				tr += "</div>";
				tr += "</span>";
			}
		}
		$("#shipin_").html(tr);
		lunboshow();
	},'json')
});

//二级
function erji(id,index) {
		var tr = "";
		tr += "<div class=\"col-c\">";
		tr += "<div class=\"pic\">";
	
		var map = {};
		map["fflid"]=id;
		map["type"]="1";
		var action8 = "/appsfenlei/selectSFenleikc.ph";
		ajaxPostAsyncData(action8, map, function(data8) {
			var obj8 = data8.resobj.rows;
			var img = obj8[0].imgpcurl;
			var action9 = "/appSShipin/selectByshipin.ph";
			var map1 = {};
			map1["index"]=7;
			map1["zjid"]=obj8[0].zjid;
			ajaxPostAsyncData(action9, map1, function(data9) {
				var obj9 = data9.resobj.rows;
				for(var k=0;k<obj9.length;k++) {
					if(k==0) {
						tr += "<a href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\">";
						tr += "<p>"+obj9[k].name+"</p></a>";
						tr += "</div>";
						tr += "</div>";
						tr += "<div class=\"col-r\">";
						tr += "<div class=\"ul-video\">";
						tr += "<ul>";
					}else {
						tr += "<li><a href=\"kechengxiangqing.html?zjid="+obj9[k].zjid+"&kcid="+obj8[0].zjid+"\"><img style=\"width: 100%;\" src=\""+obj9[k].imgpcurl+"\" alt=\"\"><p>"+obj9[k].name+"</p></a></li>";
					}
				}
			},'json')
		},'json')
	tr += "</ul>";
	tr += "</div>";
	tr += "</div>";
	tr += "</div>";
	$(".erjis"+index+"").html(tr);
}

//轮播图
function lunboshow() {
    // 轮播图
    jQuery(".bj").slide({titCell:".hd ul",mainCell:".bd ul",effect:"fold",autoPage:"<li><a></a></li>",autoPlay:true,startFun:function(i,c){ 
                $('.bj li.on').removeClass('on');
        },endFun:function(i,c){ 
                $('.bj li').eq(i).addClass('on');
        }});
    jQuery(".box-bj1").slide({titCell:".hd ul",mainCell:".bd ul",effect:"fold",autoPage:"<li><a></a></li>",autoPlay:true,startFun:function(i,c){ 
                $('.box-bj1 li.on').removeClass('on');
        },endFun:function(i,c){ 
                $('.box-bj1 li').eq(i).addClass('on');
        }});
    jQuery(".box-bj2").slide({titCell:".hd ul",mainCell:".bd ul",effect:"fold",autoPage:"<li><a></a></li>",autoPlay:true,startFun:function(i,c){ 
                $('.box-bj2 li.on').removeClass('on');
        },endFun:function(i,c){ 
                $('.box-bj2 li').eq(i).addClass('on');
        }});

    jQuery(".banner-list").slide({titCell:".banner-list-tab ul li",mainCell:".list-vedio",effect:"leftLoop",autoPlay:false})
}


